﻿using UnityEngine;
using FrameWorkSong;
public class ResolutionControl : MonoBehaviourSimplify
{
    Resolution[] resolutions;
    public Resolution MaxResolutions;
    Resolution resolution;
    public override void OnBeforeDestroy()
    {
     
    }

    // Start is called before the first frame update
    void Start()
    {
        resolutions = Screen.resolutions;
        int count = resolutions.Length;
        MaxResolutions = resolutions[count - 1];
        Debug.Log(MaxResolutions.height + "*" + MaxResolutions.width);
        resolution = MaxResolutions;
        SetMaxWindows();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            MaxWindows();
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            MinWindows();
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            SamllWindows();
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            FullWindows();
        }
        if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            MaxScreenBar();
        }
     
    }
    //全屏有工具栏无标题
    void MaxWindows()
    {
        // SetMaxWindows();
        SetResolution(resolution.width, resolution.height - GetTaskBarHeight(), false, false, 0, 0);
    }
    //有工具栏有标题
    void MinWindows()
    {
        SetResolution(1080, 720, false, true, (int)((resolution.width-1080)*0.5f), (int)((resolution.height - 720) * 0.5f));
    }
    //最小化
    void SamllWindows()
    {
        SetMinWindows();
    }
    //全屏有工具栏有标题
    void MaxScreenBar()
    {
        SetResolution(resolution.width, resolution.height-GetTaskBarHeight(), false, true,0,0);
    }
    //全屏无工具栏无标题
    void FullWindows()
    {
        SetResolution(720, 480, true, true, 0,0);
    }
}
